package com.xy.mq.product;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component("testProducter")
public class TestProducter {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Value("${com.xy.customer.topic}")
    private String testTopic;

    public void sendMessage() {
        Message<String> msg = MessageBuilder.withPayload("Hello,First boot RocketMQ").build();
        rocketMQTemplate.convertAndSend(testTopic, msg);
    }

}
